package structure;

import java.util.ArrayList;

public class Frame {

	String title;
	ArrayList<Point> points;
	int height ;
	
	public Frame(){
		points = new ArrayList<Point>();
	}
	
	public Frame(String title){
		this.title = title;
		points = new ArrayList<Point>();
	}
	
	public void addPoint(Point p){
		points.add(p);
	}
	
	
	public ArrayList<Point> getPoints(){
		return points;
	}
	
	public int[] toArrayOfXyPoints(){
		int[] xyPoints = new int[points.size()*2];
		int xyCounter = 0;
		for(int i = 0; i < points.size(); i++){
			int[] xy = points.get(i).toCartesianCoordinates();
			xyPoints[xyCounter++] = xy[0];
			xyPoints[xyCounter++] = xy[1];
		}
		return xyPoints;
	}
	
	public int getHeight() {
		for (int myiter = 0; myiter < points.size(); myiter+=1){ 
		    int result = (int) Math.floor(points.get(myiter).getR() * Math.sin(points.get(myiter).getTheta()*Math.PI/180));
			if (result > height) height = result ;
		}
		return height ;
	}
	
	public String toString(){
		String str = title;
		for(Point p : points)
			str += "\n" + p;
		return str;
	}

}